package com.hust.bridgecheck.serviceImpl.BridgeSensor;

import com.hust.bridgecheck.entity.Bridge;
import com.hust.bridgecheck.repository.BridgeRepository;
import com.hust.bridgecheck.service.BridgeSensor.BridgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BridgeServiceImpl implements BridgeService {

    @Autowired
    private BridgeRepository bridgeRepository;

    @Override
    public Bridge addBridge(Bridge bridge) {
        return bridgeRepository.save(bridge);
    }

    @Override
    public List<Object> getAllBridge() {
        return bridgeRepository.getAllBridgeDomain();//自定义的方法
    }

    @Override
    public List<Bridge> findAllBridge() {
        return bridgeRepository.findAll();
    }

    @Override
    public Bridge updateBridge(Bridge bridge) {
        return bridgeRepository.save(bridge);
    }

    @Override
    public void deleteBridge(Integer briID) {
        bridgeRepository.deleteById(briID);
    }

    @Override
    public Bridge getBridgeByID(Integer briID) {
        return bridgeRepository.findById(briID).get();
    }

    @Override
    public List<Object> getDomainBridge(Integer domainid) {
        return bridgeRepository.getDomainBridge(domainid);
    }

    @Override
    public List<Object> getBridgeByName(String Bname) {
        return bridgeRepository.getBridgeByName(Bname);
    }
}
